﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using GameBase;
using Microsoft.Xna.Framework;

namespace GalaxyPresident
{
    class MotherShipView : Visble3DObject
    {
        MotherShip motherShip;
        static Texture2D TEXTURE =
            Constant.content.Load<Texture2D>(@"Resources/iconMotherShip");
        public MotherShipView(MotherShip motherShip)
        {
            this.motherShip = motherShip;
            sprite = new Sprite(TEXTURE, 1, 1);
            sprite.Color = motherShip.TeamOwner.TeamColor;
            sprite.SetOriginPosition(ORIGIN_POSITION.Center);
            if(motherShip.MotherShipTask!= null)
            {
                Vector3 d = motherShip.MotherShipTask.Target.SolarSystem.Position-
                    motherShip.MotherShipTask.Source.SolarSystem.Position;

                rotate = (float)Math.Atan(d.X / d.Y);
                if (d.Y < 0)
                {
                    rotate += (float)Math.PI;
                }
            }
        }
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            base.Update(gameTime);
            if (motherShip.MotherShipTask.Target.SolarSystem.Position == Position3D)
            {
                if (parent != null)
                {
                    parent.RemoveChild(this);
                }
                return;
            }
            Position3D = motherShip.SpacePosition;
        }


    }
}
